package com.syh.app.basic.base.view_model;

import androidx.databinding.ObservableField;

import com.syh.app.basic.bindingAdp.view_click.ClickEvent;

/**
 * 创建者：SYH
 * 时间：2019/9/29 15:17
 * 编辑者：SYH、
 * 补充说明：
 */
public class TitleViewModel {

    private ObservableField<Integer> leftDrawableRec = new ObservableField<>(0);
    private ObservableField<Integer> action1DrawableRec = new ObservableField<>(0);
    private ObservableField<Integer> action2DrawableRec = new ObservableField<>(0);
    private ObservableField<Integer> titleDrawableRec = new ObservableField<>(0);
    private ObservableField<String> titleOf = new ObservableField<>();
    private ClickEvent clickEvent;

    public TitleViewModel(Builder builder) {
        this.leftDrawableRec.set(builder.leftDrawableRec);
        this.action1DrawableRec.set(builder.action1DrawableRec);
        this.action2DrawableRec.set(builder.action2DrawableRec);
        this.titleDrawableRec.set(builder.titleDrawableRec);
        this.titleOf.set(builder.title);
        this.clickEvent = builder.clickEvent;
    }

    public ObservableField<Integer> getLeftDrawableRec() {
        return leftDrawableRec;
    }

    public ObservableField<Integer> getAction1DrawableRec() {
        return action1DrawableRec;
    }

    public ObservableField<Integer> getAction2DrawableRec() {
        return action2DrawableRec;
    }

    public ObservableField<Integer> getTitleDrawableRec() {
        return titleDrawableRec;
    }

    public ObservableField<String> getTitleOf() {
        return titleOf;
    }

    public ClickEvent getClickEvent() {
        if (clickEvent == null) throw new NullPointerException("必须要build一下 clickEvent ");
        return clickEvent;
    }

    public static final class Builder {
        int leftDrawableRec;
        int action1DrawableRec;
        int action2DrawableRec;
        int titleDrawableRec;
        String title;
        ClickEvent clickEvent;


        public Builder initLeftDrawableRec(int recId) {
            this.leftDrawableRec = recId;
            return this;
        }

        public Builder initAction1DrawableRec(int recId) {
            this.action1DrawableRec = recId;
            return this;
        }

        public Builder initAction2DrawableRec(int recId) {
            this.action2DrawableRec = recId;
            return this;
        }

        public Builder initTitleDrawableRec(int recId) {
            this.titleDrawableRec = recId;
            return this;
        }

        public Builder initTitle(String title) {
            this.title = title;
            return this;
        }

        public Builder initTitle(ClickEvent clickEvent) {
            this.clickEvent = clickEvent;
            return this;
        }

        public TitleViewModel build() {
            return new TitleViewModel(this);
        }


    }

}
